<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets the handler called when a server message is raised</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.sybase-set-message-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sybase_set_message_handler</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">sybase_set_message_handler</span> &mdash; <span class="dc-title">Sets the handler called when a server message is raised</span></p>

 </div>
 
 <div id="function.sybase-set-message-handler-refsynopsisdiv">
   <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function was
<em class="emphasis">REMOVED</em> in PHP 7.0.0.</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.sybase-set-message-handler-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sybase_set_message_handler</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$handler</code></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
  ] ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>sybase_set_message_handler()</strong></span> sets a user function to
   handle messages generated by the server. You may specify the name of a
   global function, or use an array to specify an object reference and a
   method name.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sybase-set-message-handler-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">handler</code></dt>

     <dd>

      <p class="para">
       The handler expects five arguments in the following order: message
       number, severity, state, line number and description.  The first four
       are integers. The last is a string. If the function returns <strong><code>FALSE</code></strong>,
       PHP generates an ordinary error message.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">link_identifier</code></dt>

     <dd>

      <p class="para">
       If the link identifier isn&#039;t specified, the last opened link is assumed.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sybase-set-message-handler-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sybase-set-message-handler-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2597">
    <p><strong>Example #1 <span class="function"><strong>sybase_set_message_handler()</strong></span> callback function</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">msg_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">sybase_set_message_handler</span><span style="color: #007700">(</span><span style="color: #DD0000">'msg_handler'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
   <div class="example" id="example-2598">
    <p><strong>Example #2 <span class="function"><strong>sybase_set_message_handler()</strong></span> callback to a class</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Sybase&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$sybase</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Sybase</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">sybase_set_message_handler</span><span style="color: #007700">(array(</span><span style="color: #0000BB">$sybase</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'handler'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
   <div class="example" id="example-2599">
    <p><strong>Example #3 <span class="function"><strong>sybase_set_message_handler()</strong></span> unhandled messages</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Return&nbsp;FALSE&nbsp;from&nbsp;this&nbsp;function&nbsp;to&nbsp;indicate&nbsp;you&nbsp;can't&nbsp;handle<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;this.&nbsp;The&nbsp;error&nbsp;is&nbsp;printed&nbsp;out&nbsp;as&nbsp;a&nbsp;warning,&nbsp;the&nbsp;way&nbsp;you're&nbsp;used<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;to&nbsp;it&nbsp;if&nbsp;there&nbsp;is&nbsp;no&nbsp;handler&nbsp;installed.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">msg_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">257&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$msgnumber</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$severity</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$state</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">sybase_set_message_handler</span><span style="color: #007700">(</span><span style="color: #DD0000">'msg_handler'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.sybase-set-message-handler-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数仅适用于对 Sybase 使用 CT 库接口，而不适用于 DB 库。</span></p></blockquote>
 </div>


</div></div></div></body></html>